//
//  Codable+Ext.swift
//  yasee_plugin
//
//  Created by Henry Gao on 2024/8/21.
//

import Foundation


/// 扩展 
extension Encodable where Self: Codable {
    
    /// json 对象 [:]
    var json: Any? {
        do {
            let encoder = JSONEncoder()
            let data = try encoder.encode(self)
            let jsonObject = try JSONSerialization.jsonObject(with: data, options: .fragmentsAllowed)
            return jsonObject
        } catch {
            print("Failed to convert to JSON: \(error)")
            return nil
        }
    }
    
}


